# Contributor: Bart Ribbers <bribbers@disroot.org>
# Maintainer: Marco Schröder <marco.schroeder96@gmail.com>
pkgname=amazfish
pkgver=2.2.2
pkgrel=0
_commit_qble="3631992ff3bf71a4680f18487e05486c134a1805"
_commit_libwatchfish="b8e2e8c0d2e2b17153823ef7ca18d5b73b0dabe3"
pkgdesc="Companion application for Huami Devices (such as Amazfit Bip, Cor, MiBand2/3 and GTS and GTS) and the Pinetime Infinitime"
url="https://github.com/piggz/harbour-amazfish"
# armhf blocked by kdb
arch="all !armhf"
license="GPL-3.0-or-later"
depends="
	bluez
	bluez-qt5
	kdb-sqlite
	kirigami2
	nemo-qml-plugin-dbus
	qt5-qtconnectivity
	qt5-qtquickcontrols
	"
makedepends="
	icu-dev
	karchive5-dev
	kdb-dev
	qt5-qtbase-dev
	qt5-qtconnectivity-dev
	qt5-qtlocation-dev
	qtmpris-dev
	"
source="https://github.com/piggz/harbour-amazfish/archive/$pkgver/harbour-amazfish-$pkgver.tar.gz
	https://github.com/piggz/qble/archive/$_commit_qble/qble-$_commit_qble.tar.gz
	https://github.com/piggz/libwatchfish/archive/$_commit_libwatchfish/libwatchfish-$_commit_libwatchfish.tar.gz
	amazfish-launcher.sh
	amazfish.desktop
	"
options="!check" # No tests
builddir="$srcdir/harbour-amazfish-$pkgver"

prepare() {
	default_prepare

	rmdir qble daemon/libwatchfish
	mv "$srcdir/qble-$_commit_qble" qble
	mv "$srcdir/libwatchfish-$_commit_libwatchfish" daemon/libwatchfish
}

build() {
	qmake-qt5 \
		PREFIX=/usr \
		FLAVOR=kirigami
	make
}

package() {
	make INSTALL_ROOT="$pkgdir" install

	install -Dm644 "$srcdir"/amazfish.desktop -t "$pkgdir"/etc/xdg/autostart/
	install -Dm755 "$srcdir"/amazfish-launcher.sh "$pkgdir"/usr/libexec/amazfish-launcher

	# We don't ship systemd
	rm -r "$pkgdir"/usr/lib/systemd
}

sha512sums="
2b12c77496c3c0319f6bb4dbac940cca5eab49052c247549e65ad6e85170830d35058e10d7046ec1b112b36b0bf66ca7abbd891e42f273303d6b8a344c8055d5  harbour-amazfish-2.2.2.tar.gz
551b2c4eefbfa269975da458ebbbfd6fb5346990224adb72cba322c97972b5343515e73aae351c3b18af6c8b9dc2f6da82966f3eca4780effdf978c50845a3dc  qble-3631992ff3bf71a4680f18487e05486c134a1805.tar.gz
6d2c7c644edbd7b99b34fb0f6e117ccae67935da9c067c9e73b717a3eb617b259b0184148d79d8e8636f6332fe4013427c3d0400d79622acd149bad9eef96b9d  libwatchfish-b8e2e8c0d2e2b17153823ef7ca18d5b73b0dabe3.tar.gz
a17c0d6578e0d6878099f9c913e54100c44dbb94cf8803f2780d5709ec08136daa832ec2ffe947fb8a91e02320f01041d0e763bcc08350270af36d89f767ca14  amazfish-launcher.sh
930f2cae5f88559a83dd46d11d2161a9239efdd46ad6b91dc530eb4a7863f197a7865f9599973b71bcc7d1e2346c848ea7b9a57f5b714560d101b0f384c0f4d1  amazfish.desktop
"
